package de.lot.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * ProgramOfStudy holds a list of associated students and program goals.
 * It describes the programCode and the name of a program of study.
 * 
 * @author Stefan Kohler <kohler.stefan@gmail.com>
 */

@Entity
@Table(name = "PROGRAMOFSTUDY")
public class ProgramOfStudy implements Serializable {

    private Long id;
    private String programCode;
    private String name;
    private Set<Student> studentList = new HashSet<Student>();
    private Set<ProgramGoal> programGoalList = new HashSet<ProgramGoal>();

    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Length(max = 30)
    @NotNull
    public String getProgramCode() {
        return programCode;
    }

    public void setProgramCode(String programCode) {
        this.programCode = programCode;
    }

    @Length(max = 50)
    @NotNull
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "programOfStudy")
    public Set<Student> getStudentList() {
        return studentList;
    }

    public void setStudentList(Set<Student> studentList) {
        this.studentList = studentList;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    public Set<ProgramGoal> getProgramGoalList() {
        return programGoalList;
    }

    public void setProgramGoalList(Set<ProgramGoal> programGoalList) {
        this.programGoalList = programGoalList;
    }
}
